﻿
@model RTW.OA.Models.official_document
@{

    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}

@section styles{

}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h4>@ViewBag.Title </h4>
            </div>
            <div class="ibox-content">
                @using (Html.BeginForm("Edit", "Send", FormMethod.Post, new { area = "Document", id = "form", name = "form" }))
                {
                    @Html.AntiForgeryToken()

                    <div class="from-content">
                        <dl>
                            <dt>公文标题</dt>
                            <dd>
                                @Html.EditorFor(m => m.SUBJECT, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>正文</dt>
                            <dd>
                                @Html.TextAreaFor(m => m.BODY, new { @class = "editor" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>紧急程度</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("URGENT_LEVEL", ViewBag.URGENT_LEVEL_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>秘密等级</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("SECRET_LEVEL", ViewBag.SECRET_LEVEL_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>发文页数</dt>
                            <dd>
                                @Html.TextBoxFor(m => m.DOC_PAGE_COUNT, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>拟稿单位</dt>
                            <dd>
                                @Html.EditorFor(m => m.DRAFT_UNIT, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>拟稿人</dt>
                            <dd>
                                @Html.EditorFor(m => m.DRAFT_AUTHOR, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>主送单位</dt>
                            <dd>
                                @Html.TextArea("RECEIVE_UNITS_TEXT", new { @class = "input normal form-control", @readonly = "readonly" })
                                @Html.HiddenFor(m => m.RECEIVE_UNITS)
                                <div>
                                    <input type="button" value="全省院" onclick="applyText(this, 'RECEIVE_UNITS_TEXT');" />
                                    <input type="button" value="中院" onclick="applyText(this, 'RECEIVE_UNITS_TEXT');" />
                                    <input type="button" value="基层院" onclick="applyText(this, 'RECEIVE_UNITS_TEXT');" />
                                    <input type="button" value="本院部门" onclick="applyText(this, 'RECEIVE_UNITS_TEXT');" />
                                    <input type="button" value="审判业务部门" onclick="applyText(this, 'RECEIVE_UNITS_TEXT');" />
                                    <input type="button" value="细选" onclick="selectReceiver();" />
                                    <input type="button" value="清空" onclick="clearText('RECEIVE_UNITS');" />
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>接收人</dt>
                            <dd>
                                @Html.TextArea("RECEIVERS_TEXT", new { @class = "input normal form-control", @readonly = "readonly" })
                                @Html.HiddenFor(m => m.RECEIVERS)
                                <div>
                                    <input type="button" value="本院院领导" onclick="applyText(this, 'RECEIVERS_TEXT');" />
                                    <input type="button" value="审判业务部门" onclick="applyText(this, 'RECEIVERS_TEXT');" />
                                    <input type="button" value="本院各部门" onclick="applyText(this, 'RECEIVERS_TEXT');" />
                                    <input type="button" value="细选" onclick="selectReceiver();" />
                                    <input type="button" value="清空" onclick="clearText('RECEIVERS');" />
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>主送<br /><span style="font-size:10px;color:red;font-weight:normal;">用于套红头</span></dt>
                            <dd>
                                @Html.TextAreaFor(m => m.RED_HEAD_RECEIVE_UNITS, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>抄送<br /><span style="font-size:10px;color:red;font-weight:normal;">用于套红头</span></dt>
                            <dd>
                                @Html.TextAreaFor(m => m.RED_HEAD_CC, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>文件类别</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("DOC_CATEGORY", ViewBag.DOC_CATEGORY_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        @*<dl>
                                <dt>子类别</dt>
                                <dd>
                                    <div class="rule-single-select">
                                        @Html.TextAreaFor(m => m.DOC_SUB_CATEGORY, new { @class = "form-control" })
                                    </div>
                                </dd>
                            </dl>*@
                        <dl>
                            <dt>使用模板</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownListFor(m => m.TEMPLATE, ViewBag.TEMPLATE_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                                <a target="_blank" href="/upload/201812/06/201812061028494007.docx">下载模板</a>
                            </dd>
                        </dl>
                        <dl>
                            <dt>上传文件</dt>
                            <dd>
                                @Html.TextBoxFor(m => m.ATTACHMENT, new { @class = "input normal upload-path" })
                                <div class="upload-box upload-img"></div>
                                @if (Model != null && !string.IsNullOrEmpty(Model.ATTACHMENT))
                                {
                                    <a target="_blank" href="javascript:POBrowser.openWindowModeless('/document/send/officeview?filePath=@Model.ATTACHMENT', 'width=1200px;height=800px;');">在线预览</a>
                                }
                            </dd>
                        </dl>
                        <dl>
                            <dt>备注</dt>
                            <dd>
                                @Html.TextAreaFor(m => m.REMARK, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        @Html.HiddenFor(m => m.DOC_ID)
                        @Html.HiddenFor(m => m.DRAFT_USER_NO)
                        @Html.HiddenFor(m => m.DEPT_LEADER)
                        @Html.HiddenFor(m => m.DEPT_LEADER_USER_NO)
                    </div>
                    <div class="from-footer">
                        <div class="btn-wrap" style="position: fixed;">
                            <a class="btn btn-sm btn-primary radius" onclick="savefrom()">
                                <i class="iconfont icon-save"></i>
                                提交保存
                            </a>
                            <a class="btn btn-sm btn-warning radius" onclick="parent.subcloseTab('1301')">
                                <i class="iconfont icon-fanhui"></i>
                                取消关闭
                            </a>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/pageoffice/js/pageoffice.js")" id="po_js_main"></script>
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>

    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/uploader.js")"></script>
    @*<script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>*@

    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>
    <script>
        $(function () {
            //初始化表单验证
            $("#form").initValidform();
            $(".upload-img").InitUploader({ filesize: "@RTW.OA.Servers.CommServers.LoadSysConfig().imgsize", sendurl: "@Url.Content("~/Ashx/Upload_ajax.ashx")", swf: "@Url.Content("~/Content/js/common/webuploader/uploader.swf")", filetypes: "@RTW.OA.Servers.CommServers.LoadSysConfig().fileextension" });
        });
        function savefrom() {
            $("#form").submit();
        }

        //初始化编辑器
        $(".editor").each(function (i) {
            var objId = $(this).attr("id");
            if (objId != "undefined") {
                var editor = UE.getEditor(objId, {
                    serverUrl: '../../../Ashx/Upload_ajax.ashx',
                    initialFrameWidth: '100%',
                    initialFrameHeight: 350
                });
            }
        });

        $(".editor-mini").each(function (i) {
            var objId = $(this).attr("id");
            if (objId != "undefined") {
                var editorMini = UE.getEditor(objId, {
                    serverUrl: '../../../Ashx/Upload_ajax.ashx',
                    initialFrameWidth: '100%',
                    initialFrameHeight: 250,
                    toolbars: [[
                        'fullscreen', 'source', '|', 'undo', 'redo', '|',
                        'bold', 'italic', 'underline', 'strikethrough', 'removeformat', 'pasteplain', '|', 'forecolor', 'insertorderedlist', 'insertunorderedlist', '|',
                        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                        'link', 'unlink', 'anchor', '|',
                        'simpleupload', 'insertimage', 'scrawl', 'insertvideo'
                    ]]
                });
            }
        });

        function applyText(cid, tid) {
            var text = $("#" + tid).val();
            text += text != "" ? "," + $(cid).val() : $(cid).val();
            $("#" + tid).val(text);
        }

        function clearText(tid) {
            $("#" + tid).val("");
            $("#" + tid+"_TEXT").val("");
        }

        function selectReceiver() {
            var id = $('#DOC_ID').val();
                layer.open({
                    type: 2,
                    shadeClose: true,
                    shade: 0.8,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['80%', '90%'], //宽高
                    content: '@Url.Action("SelectReceiver", "Send", new { area = "Document" })\/' + id
                });
        }

        function setReceiver(data) {
            $('#RECEIVE_UNITS_TEXT').val(data.dtext_list.join(','));
            $('#RECEIVE_UNITS').val(data.did_list.join(','));
            $('#RECEIVERS_TEXT').val(data.utext_list.join(','));
            $('#RECEIVERS').val(data.uid_list.join(','));
        }
    </script>

}